package org.chen.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@Data
@Builder
public class VideoGenerateRequest {
    private Boolean caption;
    private String title;
    // 注意这里使用 @JsonProperty 来保证序列化后的字段名正确
    @JsonProperty("callback_id")
    private String callbackId;
    private Dimension dimension;
    @JsonProperty("video_inputs")
    private List<VideoInput> videoInputs;
    @JsonProperty("callback_url")
    private String callbackUrl;
    @JsonProperty("aspect_ratio")
    private String aspectRatio;
    private boolean test;

    @Data
    @Builder
    public static class Dimension {
        private Integer width;
        private Integer height;
    }

    @Data
    @Builder
    public static class VideoInput {
        private Character character;
        private Voice voice;
        private Background background;
    }

    @Data
    @Builder
    public static class Character {
        private String type;
        @JsonProperty("avatar_id")
        private String avatarId;
        private Double scale;
        @JsonProperty("avatar_style")
        private String avatarStyle;
        private Offset offset;
    }

    @Data
    @Builder
    public static class Voice {
        private String type;
        @JsonProperty("voice_id")
        private String voiceId;
        @JsonProperty("input_text")
        private String inputText;
    }

    @Data
    @Builder
    public static class Background {
        private String type; // "color", "image", "video"

        // 用于颜色背景
        private String color;

        // 用于图片和视频背景
        private String url;
        private String fit; // "crop", "cover", 等

        // 仅用于视频背景
        @JsonProperty("play_style")
        private String playStyle; // "loop", "once", 等

        @JsonProperty("video_asset_id")
        private String videoAssetId;

        @JsonProperty("image_asset_id")
        private String imageAssetId;
    }

    @Data
    @Builder
    public static class Offset {
        private double x;
        private double y;
    }
}